package users

import (
	"go_auth/ext/settings"
	"go_auth/models/users"
	"go_auth/utils/commons"
	"go_auth/utils/redis"
	"strconv"
)

type Per struct {
	users.Per
}

func (p *Per) GetAllPer(size int) interface{} {
	return users.GetAllPer(size)
}

func (p *Per) UpdatePer() int64 {
	return p.Per.UpdatePer()
}

func (p *Per) AddPer() int64 {

	return p.Per.AddPer()
}

func (p *Per) DeletePer() int64 {

	return p.Per.DeletePer()
}

/**
这里重新规划
*/
func InitPer() {
	per, err := users.InitPer()
	if commons.CheckErr(err) {
		for _, v := range per {
			str := strconv.Itoa(v.PerId)
			redis.SetStringValue(v.Url, commons.StringJoin([]string{str, "_", v.Method}), 60*60*24*30*36, settings.RDb0)
			redis.SetStringValue(commons.StringJoin([]string{str, "_", v.Method}), v.Url, 60*60*24*30*36, settings.RDb3)
		}
	}

}
